//  Created by wealthgrow on 2020/7/7.
//  Copyright © 2020 qimeng. All rights reserved.

#import "TPEnum.h"

@implementation TPEnum

//处理返回多个状态，需要枚举值相加的问题
//疑问❓：这个地方，我进行了优化，枚举值相加改为或
+ (CourseOrderType)realOrderStatusWith:(NSInteger)status {
    if (status == CourseOrderTypePaying ||
        status == (CourseOrderTypePaying | CourseOrderTypeAuth)) {

        return CourseOrderTypePaying;

    } else if (status == CourseOrderTypePayed ||
               status == (CourseOrderTypePayed | CourseOrderTypeAuth)) {

        return CourseOrderTypePayed;

    } else if (status == CourseOrderTypeCancel ||
               status == (CourseOrderTypeCancel | CourseOrderTypeAuth)) {

        return CourseOrderTypeCancel;

    } else if (status == CourseOrderTypeRefunded ||
               status == (CourseOrderTypeRefunded | CourseOrderTypeAuth)) {

        return CourseOrderTypeRefunded;

    } else {
        return CourseOrderTypeNone;
    }
}

+ (FileType)fileTypeWithPath:(NSString *)path {
    if (path.length == 0) {
        return FileTypeNone;
    }
    NSString *lowerPath = [path lowercaseString];
    if ([lowerPath containsString:@".mp4"]) {
        return FileTypeVideo;
    }
    if ([lowerPath containsString:@".doc"] ||
        [lowerPath containsString:@".docx"]
        ) {
        return FileTypeDoc;
    }
    if ([lowerPath containsString:@".pdf"]
        ) {
        return FileTypePDF;
    }

    if ([lowerPath containsString:@".ppt"] ||
        [lowerPath containsString:@".pptx"]
        ) {
        return FileTypePPT;
    }

    if ([lowerPath containsString:@".jpg"] ||
        [lowerPath containsString:@".png"] ||
        [lowerPath containsString:@".jpeg"]
        ) {
        return FileTypeImage;
    }

    return FileTypeNone;
}

//课件类型：-1模型 1视频 2PPT 3动画 4知识速记 5图谱 6图片 7音频 8笔记 16交互实验(目前就是视频) 32切片 48标本 64测验 65三维动画
+ (NSString *)courseWareTextWith:(NSInteger)type {
    if (type == CoursewareTypeAnatomy) { //-1
        return @"模型";

    } else if (type == CoursewareTypeVideo) { //1
        return @"视频";

    } else if (type == CoursewareTypePPT) { //2
        return @"PPT";

    } else if (type == CoursewareTypeAnimation) { //3
        return @"动画";

    } else if (type == CoursewareTypeKnowledgeImage) { //4
        return @"知识速记";

    } else if (type == CoursewareTypeImage) { //5
        return @"图谱";

    } else if (type == CoursewareTypePic) { //6
        return @"图片";

    } else if (type == CoursewareTypeAudio) { //7
        return @"音频";

    } else if (type == CoursewareTypeNote) { //8
        return @"考点速记";

    } else if (type == CoursewareTypeJiaohuExp) { //16
        return @"交互实验";

    } else if (type == CoursewareTypeSide) { //32
        return @"切片";

    } else if (type == CoursewareTypeBiaoBen) { //48
        return @"标本";

    } else if (type == CoursewareTypeTest) { //64
        return @"测验";

    } else if (type == CoursewareType3DAnimation) { //65
        return @"三维动画";

    } else {
        return @"";
    }
}

+ (UIImage *)imageFromCoursewareResourceType:(CoursewareResourceType)coursewareResourceType{
    NSString *imgStr = @"courseware_test";
    switch (coursewareResourceType) {
        case CoursewareTypeVideo:
            imgStr = @"courseware_video";
            break;

        case CoursewareTypePPT:
            imgStr = @"courseware_ppt";
            break;

        case CoursewareTypeKnowledgeImage:
            imgStr = @"courseware_img";
            break;

        case CoursewareTypeNote:
            imgStr = @"courseware_note";
            break;

        case CoursewareTypeJiaohuExp:
            imgStr = @"courseware_jiaohu";
            break;

        case CoursewareTypeSide:
            imgStr = @"courseware_side";
            break;

        case CoursewareTypeBiaoBen:
            imgStr = @"courseware_biaoben";
            break;

        case CoursewareTypeTest:
            imgStr = @"courseware_test";
            break;
        default:
            break;
    }
    return [UIImage imageNamed:imgStr];
}

+ (NSString *)quesTypeStrWithAlias:(QuestionAlias)alias {
    if (alias == QuestionAliasSingleSelect) {
        return @"单选题";

    } else if (alias == QuestionAliasMultiSelect) {
        return @"多选题";

    } else if (alias == QuestionAliasTureOrFalse) {
        return @"判断题";

    } else if (alias == QuestionAliasFill) {
        return @"填空题";

    } else if (alias == QuestionAliasShorAnswer || alias == QuestionAliasShorAnswer_Another) {
        return @"简答题";

    } else if (alias == QuestionAliasNameParsing || alias == QuestionAliasNameParsing_Another) {
        return @"名词解释";

    } else if (alias == QuestionAliasOperation || alias == QuestionAliasOperation_Another) {
        return @"操作题";

    } else {
        return @"";
    }
}

+ (QuestionType)quesTypeWithStr:(NSString *)quesTypeStr {
    if ([quesTypeStr isEqualToString:@"单选题"]) {
        return QuestionTypeSingleSelect;

    } else if ([quesTypeStr isEqualToString:@"多选题"]) {
        return QuestionTypeMultiSelect;

    } else if ([quesTypeStr isEqualToString:@"判断题"]) {
        return QuestionTypeTureOrFalse;

    } else if ([quesTypeStr isEqualToString:@"填空题"]) {
        return QuestionTypeFill;

    }else if ([quesTypeStr isEqualToString:@"简答题"]) {
        return QuestionTypeShorAnswer;

    }else if ([quesTypeStr isEqualToString:@"名词解释"]) {
        return QuestionTypeNameParsing;
    }
    else if ([quesTypeStr isEqualToString:@"操作题"]) {
        return QuestionTypeOperation;
    }
    else {
        return QuestionTypeNone;
    }
}
@end


